/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: AudioTypes.hpp,v 1.3 2009-10-21 14:58:55 morsko Exp $
 *
 * \file AudioTypes.hpp
 * \brief MaCI - Audio interface type definitions
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 */
#ifndef _MACI_INTERFACE_AUDIOTYPES_HPP_
#define _MACI_INTERFACE_AUDIOTYPES_HPP_
#include <inttypes.h>
#include <string.h>
#include "owndebug.h"

namespace MaCI {
  
  /** MaCI - Audio Interface
   *
   * This namespace contains all the methods and types related to
   * the MaCI - Audio Interface
   *
   */
  namespace Audio {
    

    /**
     * Type identifiers inside BinBag frame. Used for dynamic encoding/decoding
     * of message frames
     *
     */
    enum EAudioElementType { 
      KTypeUnknown     = -1,  ///< Unknown type
      KTypeTimestamp   = 1,   ///< Contains a timestamp (TTimestamp)
      KTypeAudioInfo   = 2,   ///< Audio information.
      KTypeAudioData   = 3,   ///< Contains Audiodata. (raw - uncompress/use directly)
      KTypeCommand     = 4    ///< Contains a command (TCommand)
    };

    /** 
     * Currently defined ayduie formats. This enum is used inside
     * TAudioInfo container. 
     */
    enum EAudioDataType { 
      KAudioDataUnknown   = 0,  ///< Unknown (not set) type.
      KAudioDataRaw       = 1,  ///< Raw audioformat. (Unknown to Interface, Avoid this!)
      KAudioDataPCMS8     = 2,  ///< PCM Signed 8 bit 
      KAudioDataPCMS16    = 3,  ///< PCM Signed 16 bit Little Endian
      KAudioDataPCMS32    = 4,  ///< PCM Signed 32 bit Little Endian

    };
    /** 
     * Commands available (Commands are paired with appropriate following dataelements)
     */
    enum EAudioCommand { 
      KCommandUnknown  = -1,         ///< Unknown type
      KCommandGetAudioInfo = 1,
      KCommandGetAudioInfoReply = 2,
      KCommandNewAudio = 3           ///< Got new audio period. 
    };

    /**
     * Describes Commands for Audio interface
     *
     */
    struct TCommand {
      TCommand(EAudioCommand aCmd = KCommandUnknown) 
	: cmd(aCmd) {}
      
      uint32_t cmd; ///< Command \see EAudioCommand
    };
    
    /**
     * Audio Information field.
     */
    struct TAudioInfo {
      TAudioInfo(const EAudioDataType aAudioDataType = KAudioDataUnknown,
                 const unsigned int aFrequency = 0,
                 const unsigned int aNumberOfChannels = 0,
                 const unsigned int aNumberOfFrames = 0)
        : audiodatatype(aAudioDataType),
          frequency(aFrequency),
          numberOfChannels(aNumberOfChannels),
          numberOfFrames(aNumberOfFrames) 
      {
      }

      uint32_t audiodatatype;    ///< Datatype of following dataelement. (see EAudioDataType)
      uint32_t frequency;       ///< Frequency in kHz
      uint32_t numberOfChannels; ///< Number of channels
      uint32_t numberOfFrames;  ///< Number of frames in buffer
      
    };
  

  }
}





#endif
